////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//                           BailterRay                                       //
//                    Pip Robbins & Zhao Zhang                                //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
class BailterRayPlayerController extends UTPlayerController;

var float lastTimeStamp; // Stores last time to calc delta time.
var vector cameraAdjustment; // Camera Position.
var bool bFacingRight; // Direction of player's character.
var float xAdjustmentTime; // Stores time performing X camera adjustment.
var float zLastPlayerPosition; // The last Z player position for camera adjustment.
var bool bZThresholdReached; // Flag used to see if camera needs moving in Z axis.
var float yGamePlane; // Stores the current y plane the character is using.
var rotator pRotation; // The real rotation of the player for new controls.
var vector pDirection; // The real direction of the player for old controls.
var float maxJumpVelocity; // Stores the players highest velocity for jump pads.
var float MouseAdjustment; // Mouse sensitivity for old controls.
var bool bDodging;
var bool bDodgeGaugeZero;
var class <UTLocalMessage> MyMessageClass;
var float DodgeTimeLimit;
var float Controller_RightY;
var float Controller_RightX;
var float Controller_LeftX;
var float Controller_LeftY, oldController_LeftY;
var int CurrentSamples;

const MAX_X_OFFSET            = 200; // Max camera X offset.
const X_ADJUSTMENT_SPEED      = 1.5; // Time taken for camera adjust from player to max offset.
const MAX_Y_OFFSET            = 750; // Distance camera zooms out when crouching.
const Y_OFFSET                = 550; // Normal distance camera is from player.
const CAMERA_ZOOM_SPEED       = 4; // Camera speed zooming in and out.
const CAMERA_RETURN_SPEED     = 1; // Camera speed when returning from zoom.
const CAMERA_SENSITIVITY      = 0.01; // General camera speed.
const Z_OFFSET_THRESHOLD      = 150; // Threshold before camera will start adjusting.
const Z_ADJUSTMENT_SPEED      = 3; // Speed of vertical camera adjustment.
const Z_OFFSET                = 100; // The Z vertical height of the camera
const DODGE_TIME_LIMIT	      = 10;  // Cooldown time on dodging
const DODGE_TIME              = 1.4; // How long it takes to perform the dodge
const MOUSE_SENSITIVITY	      = 0.00025; // Mouse Sensitivity
const FALL_VELOCITY_DECREASE  = 120; // How much decrease in X acceleration while falling
const MAX_CHANGE_IN_AIM       = 25000;

// Force third-person.
function SetBehindView(bool bNewBehindView)
{
	super.SetBehindView(true);
}

// Update Hud and force Y positioning.
function PlayerTick(float DeltaTime)
{
	super.PlayerTick(DeltaTime);
    UpdateHud(DeltaTime);
    EnforcePlayerPosition();
    TraceJumpVelocity();
    UpdateLeftStick();
    if(self.IsDead())
        DodgeTimeLimit = 10;
}

// Forces Player to stay at the same Y value
// Stops players falling off the map or getting off course
// Forces Player to stay at the same Y value
// Stops players falling off the map or getting off course
function EnforcePlayerPosition()
{
    local vector locationFix;
    local BailterRayPawn P;

	// Makes View Target the player.
	if(ViewTarget != None)
    {
        P = BailterRayPawn(ViewTarget);
    }
    if(P != none)
    {
        if(!bDodging)
        {
            if(P.Location.Y != yGamePlane)
            {
                locationFix = P.Location;
                locationFix.Y = yGamePlane;
                P.Move(locationFix - P.Location);
                P.Velocity.Y = yGamePlane - P.Location.Y;
            }
            else
            {
                P.Velocity.Y = 0;
            }
        }
    }
}

// Change the camera Position
function SetCameraAdjustment(float X, float Y, float Z, optional float xTime)
{
    cameraAdjustment.X = X;
    cameraAdjustment.Y = Y;
    cameraAdjustment.Z = Z;
    xAdjustmentTime = xTime;
}

// Third-person camera.
simulated event GetPlayerViewPoint(out vector POVLocation, out Rotator POVRotation)
{
    local float DeltaTime;
    local float CameraAdjSpeed;
    local BailterRayPawn P;
    local vector CameraRotation;
    local float zDeltaPosition;

    if(bCinematicMode == true)
    {
        super.GetPlayerViewPoint(POVLocation, POVRotation);
        return;
    }

    // Gets change in time since last ViewPoint call.
   	DeltaTime = WorldInfo.TimeSeconds - lastTimeStamp;
	lastTimeStamp = WorldInfo.TimeSeconds;

    // Normalises camera adjustment speed effected by computer performance.
	CameraAdjSpeed = DeltaTime / CAMERA_SENSITIVITY;

	// Makes View Target the player.
	if(ViewTarget != None)
    {
        P = BailterRayPawn(ViewTarget);
    }

    if(P != none)
    {
        // Only change camera if dodging is not in effect
        if(!bDodging) {

            // Adjust Camera's horizontal offset,
            // Give's the player more screen view based on direction of the player.
            if(!bFacingRight)
            {
                if(cameraAdjustment.X > -MAX_X_OFFSET)
                {
                    xAdjustmentTime -= DeltaTime;
                    if(xAdjustmentTime < -X_ADJUSTMENT_SPEED)
                    {
                        xAdjustmentTime = -X_ADJUSTMENT_SPEED;
                    }
                    cameraAdjustment.X = MAX_X_OFFSET * sin((0.5 * PI / X_ADJUSTMENT_SPEED ) * xAdjustmentTime);
                }
            }
            if(bFacingRight)
            {
                if(cameraAdjustment.X < MAX_X_OFFSET)
                {
                    xAdjustmentTime += DeltaTime;
                    if(xAdjustmentTime > X_ADJUSTMENT_SPEED)
                    {
                        xAdjustmentTime = X_ADJUSTMENT_SPEED;
                    }
                    cameraAdjustment.X = MAX_X_OFFSET * sin((0.5 * PI / X_ADJUSTMENT_SPEED ) * xAdjustmentTime);
                }
            }

            // Adjusts camera's distance from player when zooming in and out.
            if(P.bIsCrouched && cameraAdjustment.Y < MAX_Y_OFFSET)
            {
                cameraAdjustment.Y += CAMERA_ZOOM_SPEED * CameraAdjSpeed;
            }
            if(!P.bIsCrouched && cameraAdjustment.Y > Y_OFFSET)
            {
                cameraAdjustment.Y -= CAMERA_RETURN_SPEED * CameraAdjSpeed;
            }
            if(!P.bIsCrouched && cameraAdjustment.Y < Y_OFFSET)
            {
                cameraAdjustment.Y += CAMERA_RETURN_SPEED * CameraAdjSpeed;
            }

            // Adjusts the cameras vertical offset.
            // A uses a threshold before adjusting to allow jumping and ducking,
            // without effecting the camera
            zDeltaPosition = P.Location.Z - zLastPlayerPosition;
            cameraAdjustment.Z -= zDeltaPosition;
            if(cameraAdjustment.Z > Z_OFFSET_THRESHOLD)
            {
                cameraAdjustment.Z = Z_OFFSET_THRESHOLD;
                bZThresholdReached = true;
            }
            if(cameraAdjustment.Z < -Z_OFFSET_THRESHOLD)
            {
                cameraAdjustment.Z = -Z_OFFSET_THRESHOLD;
                bZThresholdReached = true;
            }
            if(bZThresholdReached == true && zDeltaPosition == 0 && !P.bIsCrouched)
            {
                if(cameraAdjustment.Z <= Z_OFFSET_THRESHOLD && cameraAdjustment.Z > 0)
                    cameraAdjustment.Z -= Z_ADJUSTMENT_SPEED * CameraAdjSpeed;
                if(cameraAdjustment.Z >= -Z_OFFSET_THRESHOLD && cameraAdjustment.Z < 0)
                    cameraAdjustment.Z += Z_ADJUSTMENT_SPEED * CameraAdjSpeed;
            }
            if(cameraAdjustment.Z < Z_OFFSET + 5 && cameraAdjustment.Z > Z_OFFSET - 5 && P.Physics != PHYS_Falling)
            {
                bZThresholdReached = false;
            }
            zLastPlayerPosition = P.Location.Z;
        }

        // Resets Camera if player dies
        if(P.IsInState('Dead'))
        {
            SetCameraAdjustment(MAX_X_OFFSET, Y_OFFSET, Z_OFFSET);
        }
    }

    // Set Camera location and rotation.
    CameraRotation.Y = cameraAdjustment.Y;
    POVLocation = P.Location + cameraAdjustment;
    POVRotation = rotator(-CameraRotation);

    // Apply camera changes.
    if(CameraEffect != None)
        CameraEffect.UpdateLocation(POVLocation, POVRotation, GetFOVAngle());
}

// Player fires based on their rotation
function rotator GetAdjustedAimFor(Weapon W, vector StartFireLoc)
{
   	return rotation;
}

// Effects how the player rotates.
// The player is forced to use two directions in the Yaw rotation,
// left or right.
function UpdateRotation(float DeltaTime)
{
    ////////////////////////////////////
    //        new Mouse Controls      //
    ////////////////////////////////////
	local rotator DeltaRot, newRotation;
	local vector controllerPos;

	// Changes the players direction based on mouse input.

    if((Controller_RightX > 0.5 || Controller_RightX < -0.5)  || (Controller_RightY > 0.5 || Controller_RightY < -0.5))
    {
        controllerPos.X = Controller_RightY;
        controllerPos.Z = -Controller_RightX;
        pRotation = rotator(controllerPos);
        if(Controller_RightY < 0)
            pRotation.Yaw = -32768;
        if(Controller_RightY > 0)
            pRotation.Yaw = 0;
    }

   	pRotation.Pitch += PlayerInput.aLookup;
    pRotation.Yaw += PlayerInput.aTurn * 2.5;
    // Sets the camera rotation from 0 - 180 degrees
    if(pRotation.Yaw < -32768)
        pRotation.Yaw = -32768;
    if(pRotation.Yaw > 0)
        pRotation.Yaw = 0;

    // Limits looking up to directly up stop you from looking directly down.
    if(pRotation.Pitch > 16384)
        pRotation.Pitch = 16384;
    if(pRotation.Pitch < -9192)
       pRotation.Pitch = -9192;

	newRotation = pRotation;

       if(bFacingRight == true)
    {
       if(newRotation.Yaw < -16384)
       {
           pRotation.Yaw = -32768;
       }
    }
    if(bFacingRight == false)
    {
       if(newRotation.Yaw > -16384)
       {
          pRotation.Yaw = 0;
       }
    }
    if(newRotation.Yaw < -16384)
    {
       newRotation.Yaw = -32768;
       bFacingRight = false;
    }
    if(newRotation.Yaw > -16384)
    {
       newRotation.Yaw = 0;
       bFacingRight = true;
    }

	DeltaRot = newRotation - Rotation;

    if(DeltaRot.Pitch > -32768)
    {
        if(DeltaRot.Pitch > (MAX_CHANGE_IN_AIM * DeltaTime))
        {
            DeltaRot.Pitch = (MAX_CHANGE_IN_AIM * DeltaTime);
        }
        if(DeltaRot.Pitch < (-MAX_CHANGE_IN_AIM * DeltaTime))
        {
            DeltaRot.Pitch = (-MAX_CHANGE_IN_AIM * DeltaTime);
        }
    }
    if(DeltaRot.Pitch < -32768)
    {
        if(DeltaRot.Pitch > -65536 + (MAX_CHANGE_IN_AIM * DeltaTime))
        {
            DeltaRot.Pitch = -65536 + (MAX_CHANGE_IN_AIM * DeltaTime);
        }
        if(DeltaRot.Pitch < -65536 - (MAX_CHANGE_IN_AIM * DeltaTime))
        {
            DeltaRot.Pitch = -65536 - (MAX_CHANGE_IN_AIM * DeltaTime);
        }
    }


	PlayerInput.aLookUp = DeltaRot.Pitch;
    PlayerInput.aTurn = DeltaRot.Yaw;
    super.UpdateRotation(DeltaTime);
    if(Rotation.Pitch < 32768)
    {
        pRotation.Pitch = Rotation.Pitch;
    }
    else
    {
        pRotation.Pitch = Rotation.Pitch - 65536;
    }


    ////////////////////////////////////
    //          Old Controls          //
    ////////////////////////////////////
    /* local rotator DeltaRot, newRotation;
	local vector DeltaLocation;

	// Stores the players inputs.
	pDirection.Z += PlayerInput.aLookup * MouseAdjustment;
    pDirection.X += PlayerInput.aTurn * MouseAdjustment;

    // if player is moving backward and faces right side, then turn left
    // if player is moving forward and faces left side, then turn right
	DeltaLocation.X = Location.X + PlayerInput.aStrafe;
	if((DeltaLocation.X - Location.X) < 0 && !bFacingRight)
	{
	     pDirection.X *= -1;
	     bFacingRight = true;
	}
	if((DeltaLocation.X - Location.X) > 0 && bFacingRight)
	{
	     pDirection.X *= -1;
	     bFacingRight = false;
	}

    // when player looks at upwards, don't let it turn around.
	if(!bFacingRight && pDirection.X < 0)
	    pDirection.X = 0.01;
    if(bFacingRight && pDirection.X >= 0)
        pDirection.X = -0.01;

    if(!bFacingRight && pDirection.X < 0)
	    bFacingRight = true;
    if(bFacingRight && pDirection.X >= 0)
        bFacingRight = false;

	pDirection = normal(pDirection);
	newRotation = rotator(pDirection);

    // Stop the player from aiming directly down.
    if(newRotation.Pitch < -9192)
    {
        newRotation.Pitch = -9192;
    }
    // Make the player face either forward or backwards
    if(newRotation.Yaw > 16384 || newRotation.Yaw < -16384)
    {
        newRotation.Yaw = 32768;
    }
    else
    {
        newRotation.Yaw = 0;
    }

    // Update the pDirection with any changes
    pDirection = vector(newRotation);

    // Set player input with our new values.
	DeltaRot = newRotation - Rotation;
	PlayerInput.aLookUp = DeltaRot.Pitch;
    PlayerInput.aTurn = DeltaRot.Yaw;

	super.UpdateRotation(DeltaTime);    */
}

function UpdateLeftStick()
{
     if(oldController_LeftY > -0.8 && Controller_LeftY < -0.8)
     {
         MyJump();
     }

     /*if(oldController_LeftY < 0.5 && Controller_LeftY > 0.5)
     {
        MyStartCrouch();
     }

     if(oldController_LeftY > 0.5 && Controller_LeftY < 0.5)
     {
        MyEndCrouch();
     } */
    if(Controller_LeftY >= 0.4)
     {
         MyStartCrouch();
     }
     if(Controller_LeftY - oldController_LeftY < 0 && Controller_LeftY < 0.4)
     {
         MyEndCrouch();
     }
     oldController_LeftY = Controller_LeftY;
}

state PlayerWalking
{
	function ProcessMove(float DeltaTime, vector NewAccel, eDoubleClickDir DoubleClickMove, rotator DeltaRot)
	{
		if( Pawn == None )
		{
			return;
		}
        if(Pawn.Physics == PHYS_Falling &&  PlayerInput.aStrafe == 0)
        {
           if(Pawn.Velocity.X > 0)
           {
              Pawn.Velocity.X -= FALL_VELOCITY_DECREASE * DeltaTime;
           }
           if(Pawn.Velocity.X < 0)
           {
              Pawn.Velocity.X += FALL_VELOCITY_DECREASE * DeltaTime;
           }
        }
		super.ProcessMove(DeltaTime, NewAccel, DoubleClickMove,DeltaRot);
	}

    function PlayerMove(float DeltaTime)
    {
        //Makes the player walk forward and backward with left and right keys
        PlayerInput.aForward = 0;

        // Stops player from moving while dodging.
        if(bDodging)
            PlayerInput.aStrafe = 0;

        //Makes the player strafe foward.
        Pawn.SetRotation(rot(0, -16384, 0));

        super.PlayerMove(DeltaTime);
    }
}

simulated exec function MyDodge()
{
    if ( !Pawn.bIsCrouched && !Pawn.bWantsToCrouch && Pawn.Physics != PHYS_Falling)
    {
        if(bEnableDodging)
        {
            bEnableDodging = false;
            bDodging = true;
            SetCameraAdjustment(0,415,0);
            WorldInfo.Game.SetGameSpeed(0.3);
            MouseAdjustment = 0;
            setTimer(DodgeTimeLimit,false,'EnableDodge');
            setTimer(DODGE_TIME, false, 'EndDodging');
            setTimer(DODGE_TIME/2,false,'DisableSlowDodge');
            BailterRayPawn(Pawn).Dodge(DCLICK_Active);
        }
    }
}

simulated function EndDodging()
{
    local BailterRayPawn P;
    local vector originalPos;

    WorldInfo.Game.SetGameSpeed(1);
    P = BailterRayPawn(ViewTarget);
    if(!IsInState('Dead') && !IsInState('RoundEnded') && P != none && P.IsHumanControlled())
    {
        originalPos = P.Location;
        originalPos.Y = yGamePlane;
        P.SetLocation(originalPos);
    }
    bDodging = false;
    bZThresholdReached = true;
}

simulated function EnableDodge()
{
     BailterRayHUD(MyHud).bFlashing = true;
     setTimer(0.5,false,'DisableFlash');
     bEnableDodging = true;
     bDodgeGaugeZero = false;
}

simulated function DisableSlowDodge()
{
    WorldInfo.Game.SetGameSpeed(1.5);
    MouseAdjustment = MOUSE_SENSITIVITY;
}

simulated exec function DisableFlash()
{
   BailterRayHUD(MyHud).bFlashing=false;
   BailterRayHUD(MyHud).bReadyFlash=false;
}

simulated exec function MyJump()
{
    if(!bDodging) {
        bPressedJump = true;
    }
}

simulated exec function MyStartCrouch()
{
    if(!bDodging)
    {
        bDuck = 1;
    }
}

simulated exec function MyEndCrouch()
{
    if(!bDodging)
    {
        bDuck = 0;
    }
}

function InitInputSystem()
{
	local BailterRayInteraction newInteraction;

	super.InitInputSystem();
	newInteraction = new class'BailterRay.BailterRayInteraction';
	newInteraction.MPC = self;

	LocalPlayer(Player).ViewportClient.InsertInteraction(newInteraction, 2);
}

// Saves the Y axis value and replaces team annoucement.
function AcknowledgePossession(Pawn P)
{
	local rotator NewViewRotation;

	if ( LocalPlayer(Player) != None )
	{
		AcknowledgedPawn = P;
		if ( P != None )
		{
			P.SetBaseEyeHeight();
			P.Eyeheight = P.BaseEyeHeight;
			yGamePlane = P.Location.Y;
		}
		ServerAcknowledgePossession(P);
	}

	if ( LocalPlayer(Player) != None )
	{
		ClientEndZoom();
		if (bUseVehicleRotationOnPossess && Vehicle(P) != None && UTWeaponPawn(P) == None && UTVehicle_TrackTurretBase(P) == None)
		{
			NewViewRotation = P.Rotation;
			NewViewRotation.Roll = 0;
			SetRotation(NewViewRotation);
		}
		ServerPlayerPreferences(WeaponHandPreference, bAutoTaunt, bCenteredWeaponFire, AutoObjectivePreference);

		if ( (PlayerReplicationInfo != None)
			&& (PlayerReplicationInfo.Team != None)
			&& (IdentifiedTeam != PlayerReplicationInfo.Team.TeamIndex) )
		{
			// identify your team the first time you spawn on it
			IdentifiedTeam = PlayerReplicationInfo.Team.TeamIndex;
			if ( IdentifiedTeam < 2 )
			{
				ReceiveLocalizedMessage( class'BailterRayGameMessage', IdentifiedTeam+1, PlayerReplicationInfo);
			}
		}
	}
}

// Plays start up message and sound.
function PlayAnnouncement(class<UTLocalMessage> InMessageClass, int MessageIndex, optional PlayerReplicationInfo PRI, optional Object OptionalObject)
{
    super.PlayAnnouncement(InMessageClass, MessageIndex, PRI, OptionalObject);
    MyMessageClass = InMessageClass;

}

// Plays start up message and sound.
simulated function PlayCustomAnnouncement()
{
     setTimer(9,false,'PlaySecondAnnouncement');
}

// Plays start up message and sound.
simulated exec function PlaySecondAnnouncement()
{
    ShowInfo(1);
    Announcer.PlayAnnouncement(MyMessageClass, 2);
}

// Starts the Timer.
simulated function StartIterate()
{
         setTimer(0.05,true,'UpdateIterator');
}

// Message timer.
simulated exec function UpdateIterator()
{
    if(BailterRayHUD(MyHud).Stringiterator <= Len(BailterRayHUD(MyHud).source))
        BailterRayHUD(MyHud).Stringiterator+=1;
}

// Shows Player messages.
simulated function ShowInfo(int index, optional int sec=11, optional String message = "None")
{
    BailterRayHUD(MyHud).ShowInfoMessage = message;
    BailterRayHUD(MyHud).soundindex = index;
    BailterRayHUD(MyHud).bHideInfo = false;
    BailterRayHUD(MyHud).bMoving = true;
    BailterRayHUD(MyHud).bShowInfo = true;
    setTimer(sec,false,'HideInfo');
}

// Removes messages when it expires.
simulated exec function HideInfo()
{
   BailterRayHUD(MyHud).bShowInfo = false;
   BailterRayHUD(MyHud).bMoving = true;
   BailterRayHUD(MyHud).bHideInfo = true;
   BailterRayHUD(MyHud).bInterationStarted = false;
   BailterRayHUD(MyHud).bStartPoint = true;
   ClearTimer('UpdateIterator');
   BailterRayHUD(MyHud).Stringiterator = 1;
}

// Updates the player HUD with Screen messages and dodge timer.
simulated function UpdateHud(float DeltaTime)
{
    if(BailterRayHUD(MyHud).bShowInfo && BailterRayHUD(MyHud).bMoving)
        BailterRayHUD(MyHud).CurrentPosY+=15 * BailterRayHUD(MyHud).MyResolutionScaleX;

    if(!(BailterRayHUD(MyHud).bMoving) && BailterRayHUD(MyHud).bShowInfo)
    {
         if(!(BailterRayHUD(MyHud).bInterationStarted))
         {
              StartIterate();
              BailterRayHUD(MyHud).bInterationStarted = true;

         }
    }
    if(!bEnableDodging)
    {
        if(!bDodgeGaugeZero)
        {
            BailterRayHUD(MyHud).DodgeTimeRemaining = 0;
            bDodgeGaugeZero = true;
        }
        BailterRayHUD(MyHud).DodgeTimeRemaining +=  DeltaTime;
    }
    if(bDodging)
    {
        BailterRayHUD(MyHud).DodgeTimeRemaining = 0;
        BailterRayHUD(MyHud).DodgeTimeRemaining +=  DeltaTime;
        BailterRayHUD(MyHud).BailterRayDisplayHit(Pawn.Location, 100, class'BailterRayDmgType_Dodge');
    }
}

function TraceJumpVelocity()
{
    local BailterRayPawn P;

	// Makes View Target the player.
	if(ViewTarget != None)
    {
        P = BailterRayPawn(ViewTarget);
    }
    if(P != none)
    {
        if(maxJumpVelocity < abs(P.Velocity.Z))
        {
            maxJumpVelocity = abs(P.Velocity.Z);

        }
        if(!(P.Physics == PHYS_Flying || P.Physics == PHYS_Falling))
            maxJumpVelocity = 0;
    }
}

// Forces our player to use our character model.
function LoadCharacterFromProfile(UTProfileSettings Profile)
{
	ServerSetCharacterData(class'UTCustomChar_Data'.static.CharDataFromString("AstroExplorer,ASEX,AstroExplorer_head,NONE,NONE,NONE,AstroExplorer_torso,NONE,AstroExplorer_arms,astroExplorer_thighs,astroExplorer_boots,F,F"));
	return;
}

// Removes some UT3 messages.
unreliable client function ReceiveBotVoiceMessage(UTPlayerReplicationInfo SenderPRI, int MessageIndex, object LocationObject)
{
    //do nothing!
}

function SetAutoObjective(Actor ObjectiveActor, bool bOnlyNotifyDifferent)
{
    // do nothing, dont show arrows to objectives!
}

reliable client function PlayStartupMessage(byte StartupStage)
{
   // Do not show messages!
}


// Respawn, Don't wait for player to press [FIRE]
state Dead
{
	exec function StartFire( optional byte FireModeNum )
	{
       ServerReStartPlayer();
    }

	event Timer()
	{
		if (!bFrozen)
			return;

		bFrozen = false;
		bPressedJump = false;
		ServerReStartPlayer();
	}

}

defaultproperties
{
    cameraAdjustment = (X = 200, Y = 550, Z = 100)
    pRotation = (Pitch = 0, Roll = 0, Yaw = 0) // Spawns you facing right.
    bDodging = false
    bBehindView=True
    bFacingRight = false
    bDodgeGaugeZero = false
    MouseAdjustment = MOUSE_SENSITIVITY
    xAdjustmentTime = X_ADJUSTMENT_SPEED
    DodgeTimeLimit = DODGE_TIME_LIMIT
    CurrentSamples = 0
    MinRespawnDelay=0.5
}